package tenantchannellogic

import (
	"context"
	model "gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/dao/model/tenant/channel"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/pkg/xerrors"

	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/rpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type KbzpayDailyLimitInfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewKbzpayDailyLimitInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *KbzpayDailyLimitInfoLogic {
	return &KbzpayDailyLimitInfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *KbzpayDailyLimitInfoLogic) KbzpayDailyLimitInfo(in *rpc.DailyLimitInfoRequest) (*rpc.DailyLimitInfoResponse, error) {
	var CommonResp rpc.CommonResp

	kbzpayModel := model.NewTenantChannelKbzpayModel(l.ctx, l.svcCtx.Db)
	isLimit, err := kbzpayModel.GetKbzpayIsLimit()
	if err != nil {
		CommonResp.Code = xerrors.DBError
		CommonResp.Message = "Data operation failed."
		return &rpc.DailyLimitInfoResponse{IsLimit: 0}, err
	}

	CommonResp.Message = "Success"
	return &rpc.DailyLimitInfoResponse{IsLimit: isLimit}, nil
}
